package com.fesine.crm.service.impl;

import com.fesine.crm.po.NameComparePo;
import com.fesine.crm.service.NameCompareService;
import com.fesine.service.impl.BaseServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2017/10/13 21:36
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/10/13 21:36
 */
@Service
public class NameCompareServiceImpl extends BaseServiceImpl<NameComparePo> implements
        NameCompareService {

    @Override
    public NameComparePo get(NameComparePo po) {
        //录入公司号字母大写
        setUpperPacteraNo(po);
        return daoService.selectOne(po);
    }

    @Override
    public int save(NameComparePo po) {
        //录入公司号字母大写
        po.setPacteraNo(po.getPacteraNo().toUpperCase());
        return daoService.insert(po);
    }

    @Override
    public int update(NameComparePo po) {
        //录入公司号字母大写
        setUpperPacteraNo(po);
        return daoService.update(po);
    }

    @Override
    public int delete(NameComparePo po) {
        //录入公司号字母大写
        setUpperPacteraNo(po);
        return daoService.delete(po);
    }

    @Override
    public List<NameComparePo> listAll(NameComparePo po) {
        setUpperPacteraNo(po);

        return daoService.selectList(po);
    }

    private void setUpperPacteraNo(NameComparePo po) {
        //录入公司号字母大写
        if (StringUtils.isNotBlank(po.getPacteraNo())) {
            po.setPacteraNo(po.getPacteraNo().toUpperCase());
        }
    }
}
